const express = require('express')
const router = express.Router()
const cityService = require('services/city')
const userService = require('services/user')
const config = require('config')
const passport = require('api/passport')

router.post('/wechat/login', async (req, res, next) => {
  let user = req.user
  if (user) {
    res.send(user)
  } else {
    next('weapp user auth failed')
  }
})

router.post('/bindphone',  async (req, res, next) => {
  try {
    let result = userService.bindPhone(req.user.id, req.body.mobile)
    res.send({status:'ok'})
  } catch (e) {
    next(e)
  }
})

module.exports = router